/*
 * Copyright 2012 Marsrutai.lt
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package lt.marsrutai.mobile.android.service;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;

/**
 * <p>Manipulates shapes, by changing their colors and combining with other shapes.</p>
 * <p>This enables the creation of icons with any color, provided said icons have a 
 * solid color shape template and optionally an overlay with shades, highlights etc.</p>
 * 
 * @author Justas
 */
public interface ShapeManipulationService {

    /**
     * <p>
     * Combines two resources into one {@link Drawable}. Puts the second on top
     * of the first one.
     * </p>
     * 
     * @param context
     * @param shape1Id
     *            id of a drawable resource
     * @param shape2Id
     *            id of a drawable resource
     * @return
     */
    Bitmap combineShapes(Context context, int shape1Id, int shape2Id);

    /**
     * <p>
     * Combines two {@link Drawable}s into one {@link Drawable}. Puts the second
     * on top of the first one.
     * </p>
     * 
     * @param shape1
     * @param shape2
     * @return
     */
    Bitmap combineShapes(Drawable shape1, Drawable shape2);
    
    /**
     * <p>
     * Combines two {@link Bitmap}s into one {@link Bitmap}. Puts the second
     * on top of the first one.
     * </p>
     * 
     * @param shape1
     * @param shape2
     * @return
     */
    Bitmap combineShapes(Bitmap shape1, Bitmap shape2);
    
    /**
     * <p>
     * Colors the provided shape with <code>targetColor</code>
     * </p>
     * 
     * @param drawable
     *            Shape which will have it's color changed
     * @param targetColor
     *            New shape color (transparency byte is ignored)
     * @return
     */
    Drawable colorShape(Context context, Drawable drawable, int targetColor);

    /**
     * <p>
     * Colors the provided shape with <code>targetColor</code>
     * 
     * @param shapeId
     *            id of a drawable resource
     * @param targetColor
     *            New shape color (transparency byte is ignored)
     * @return
     */
    Drawable colorShape(Context context, int shapeId, int targetColor);

    /**
     * Rotates a bitmap
     * 
     * @param context
     * @param image
     * @param degrees
     * @return
     */
    Bitmap rotateShape(Context context, Bitmap image, float degrees);

    /**
     * Converts {@link Drawable} to a {@link Bitmap}
     * 
     * @param drawable
     * @return
     */
    Bitmap drawableToBitmap(Drawable drawable);

    /**
     * Converts {@link Bitmap} to a {@link Drawable}
     * 
     * @param bitmap
     * @return
     */
    Drawable bitmapToDrawable(Context context, Bitmap bitmap);
}
